package com.yanqu.road.logic.sort.yrank;

import com.yanqu.road.entity.rank.yrank.UnionYRank;
import com.yanqu.road.utils.string.StringUtils;

import java.math.BigInteger;
import java.util.Comparator;
import java.util.Objects;

public class UnionYRankHsIslandSort implements Comparator<UnionYRank> {

    @Override
    public int compare(UnionYRank o1, UnionYRank o2) {
        if (!Objects.equals(o1.getValue(), o2.getValue())) {
            return o2.getValue().compareTo(o1.getValue());
        }
        if (!StringUtils.isNullOrEmpty(o1.getParam()) && !StringUtils.isNullOrEmpty(o2.getParam())) {
            if (!Objects.equals(o1.getParam(), o2.getParam())) {
                return new BigInteger(o2.getParam()).compareTo(new BigInteger(o1.getParam()));
            }
        }
        return Long.compare(o1.getUpdateTime(), o2.getUpdateTime());
    }

}
